package edu.cmu.fithub.db.bean;

import java.sql.Blob;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public class User {
	private int userId;
	private String username;
	private String password;
	private int age;
	private String firstName;
	private String lastName;
	private String timeZone;
	private String email;
	private int weight;
	private int numFriends = 0;
	private boolean hasImage = false;
	private Blob image;

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public String getTimeAtUserZone() {
		Calendar calendar = new GregorianCalendar(
				TimeZone.getTimeZone(timeZone));
		int hour = calendar.get(Calendar.HOUR);
		int mins = calendar.get(Calendar.MINUTE);
		int secs = calendar.get(Calendar.SECOND);
		if (calendar.get(Calendar.AM_PM) == Calendar.AM) {
			return "" + hour + ":" + ((mins < 10) ? "0" + mins : mins) + ":"
					+ ((secs < 10) ? "0" + secs : secs) + " A.M";
		} else {
			return "" + hour + ":" + ((mins < 10) ? "0" + mins : mins) + ":"
					+ ((secs < 10) ? "0" + secs : secs) + " P.M";
		}
	}

	public String getSomeTimeAtUserZone(long millis) {
		Calendar calendar = new GregorianCalendar(
				TimeZone.getTimeZone(timeZone));
		calendar.setTimeInMillis(millis);
		int hour = calendar.get(Calendar.HOUR);
		int mins = calendar.get(Calendar.MINUTE);
		int secs = calendar.get(Calendar.SECOND);
		int month = calendar.get(Calendar.MONTH);
		int day = calendar.get(Calendar.DATE);
		int year = calendar.get(Calendar.YEAR);
		if (calendar.get(Calendar.AM_PM) == Calendar.AM) {
			return "" + hour + ":" + ((mins < 10) ? "0" + mins : mins) + ":"
					+ ((secs < 10) ? "0" + secs : secs) + " A.M " + month + "/"
					+ day + "/" + year;
		} else {
			return "" + hour + ":" + ((mins < 10) ? "0" + mins : mins) + ":"
					+ ((secs < 10) ? "0" + secs : secs) + " P.M" + month + "/"
					+ day + "/" + year;
		}
	}

	public User(String username, String password, int age, String firstName,
			String lastName, String timeZone, String email, int weight,
			int numFriends, boolean hasImage) {
		super();
		this.username = username;
		this.password = password;
		this.age = age;
		this.firstName = firstName;
		this.lastName = lastName;
		this.timeZone = timeZone;
		this.email = email;
		this.weight = weight;
		this.numFriends = numFriends;
		this.hasImage = hasImage;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getTimeZone() {
		return timeZone;
	}

	public void setTimeZone(String timeZone) {
		this.timeZone = timeZone;
	}

	public int getNumFriends() {
		return numFriends;
	}

	public void setNumFriends(int numFriends) {
		this.numFriends = numFriends;
	}

	public boolean isHasImage() {
		return hasImage;
	}

	public void setHasImage(boolean hasImage) {
		this.hasImage = hasImage;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public User() {
		super();
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getEmail() {
		return email;
	}

	public Blob getImage() {
		return image;
	}

	public void setImage(Blob image) {
		this.image = image;
	}
}
